namespace RechercheEmplois.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Inital : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Domaine",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Offre",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                        NiveauEtude = c.String(),
                        Description = c.String(),
                        HoraireTravail = c.String(),
                        RenumHoraire = c.Long(),
                        DebutContrat = c.DateTime(),
                        FinContrat = c.DateTime(),
                        ExpMin = c.Int(),
                        Commentaire = c.String(),
                        DateCreated = c.DateTime(nullable: false),
                        Type = c.Int(nullable: false),
                        DomaineID = c.Int(nullable: false),
                        VilleID = c.Int(nullable: false),
                        UtilisateurID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Domaine", t => t.DomaineID)
                .ForeignKey("dbo.Utilisateur", t => t.UtilisateurID)
                .ForeignKey("dbo.Ville", t => t.VilleID)
                .Index(t => t.DomaineID)
                .Index(t => t.VilleID)
                .Index(t => t.UtilisateurID);
            
            CreateTable(
                "dbo.MotCle",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Postule",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        UtilisateurID = c.Int(nullable: false),
                        OffreID = c.Int(nullable: false),
                        DatePostule = c.DateTime(nullable: false),
                        CV = c.String(),
                        LettreMotivation = c.String(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Offre", t => t.OffreID)
                .ForeignKey("dbo.Utilisateur", t => t.UtilisateurID)
                .Index(t => t.UtilisateurID)
                .Index(t => t.OffreID);
            
            CreateTable(
                "dbo.Utilisateur",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Nom = c.String(),
                        Prenom = c.String(),
                        BirthDate = c.DateTime(),
                        TelephoneNum = c.String(),
                        Email = c.String(),
                        GroupUtilisateurID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.GroupUtilisateur", t => t.GroupUtilisateurID)
                .Index(t => t.GroupUtilisateurID);
            
            CreateTable(
                "dbo.GroupUtilisateur",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Sauvegarde",
                c => new
                    {
                        SauvegardeID = c.Int(nullable: false, identity: true),
                        UtilisateurID = c.Int(nullable: false),
                        OffreID = c.Int(nullable: false),
                        TempSauvegarde = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.SauvegardeID)
                .ForeignKey("dbo.Offre", t => t.OffreID)
                .ForeignKey("dbo.Utilisateur", t => t.UtilisateurID)
                .Index(t => t.UtilisateurID)
                .Index(t => t.OffreID);
            
            CreateTable(
                "dbo.Ville",
                c => new
                    {
                        ID = c.Int(nullable: false),
                        Libelle = c.String(),
                        ProvineID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Provine", t => t.ProvineID)
                .Index(t => t.ProvineID);
            
            CreateTable(
                "dbo.Provine",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Libelle = c.String(),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.AspNetRoles",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Name = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        UserName = c.String(nullable: false),
                        PasswordHash = c.String(),
                        SecurityStamp = c.String(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                        Utilisateur_ID = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Utilisateur", t => t.Utilisateur_ID)
                .Index(t => t.Utilisateur_ID);
            
            CreateTable(
                "dbo.AspNetUserClaims",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ClaimType = c.String(),
                        ClaimValue = c.String(),
                        User_Id = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Users", t => t.User_Id)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.AspNetUserLogins",
                c => new
                    {
                        UserId = c.String(nullable: false, maxLength: 128),
                        LoginProvider = c.String(nullable: false, maxLength: 128),
                        ProviderKey = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.UserId, t.LoginProvider, t.ProviderKey })
                .ForeignKey("dbo.Users", t => t.UserId)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.AspNetUserRoles",
                c => new
                    {
                        UserId = c.String(nullable: false, maxLength: 128),
                        RoleId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.UserId, t.RoleId })
                .ForeignKey("dbo.AspNetRoles", t => t.RoleId)
                .ForeignKey("dbo.Users", t => t.UserId)
                .Index(t => t.UserId)
                .Index(t => t.RoleId);
            
            CreateTable(
                "dbo.OffreMotcle",
                c => new
                    {
                        OffreID = c.Int(nullable: false),
                        MotCleID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.OffreID, t.MotCleID })
                .ForeignKey("dbo.Offre", t => t.OffreID, cascadeDelete: true)
                .ForeignKey("dbo.MotCle", t => t.MotCleID, cascadeDelete: true)
                .Index(t => t.OffreID)
                .Index(t => t.MotCleID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Users", "Utilisateur_ID", "dbo.Utilisateur");
            DropForeignKey("dbo.AspNetUserClaims", "User_Id", "dbo.Users");
            DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.Users");
            DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles");
            DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.Users");
            DropForeignKey("dbo.Ville", "ProvineID", "dbo.Provine");
            DropForeignKey("dbo.Offre", "VilleID", "dbo.Ville");
            DropForeignKey("dbo.Offre", "UtilisateurID", "dbo.Utilisateur");
            DropForeignKey("dbo.Sauvegarde", "UtilisateurID", "dbo.Utilisateur");
            DropForeignKey("dbo.Sauvegarde", "OffreID", "dbo.Offre");
            DropForeignKey("dbo.Postule", "UtilisateurID", "dbo.Utilisateur");
            DropForeignKey("dbo.Utilisateur", "GroupUtilisateurID", "dbo.GroupUtilisateur");
            DropForeignKey("dbo.Postule", "OffreID", "dbo.Offre");
            DropForeignKey("dbo.OffreMotcle", "MotCleID", "dbo.MotCle");
            DropForeignKey("dbo.OffreMotcle", "OffreID", "dbo.Offre");
            DropForeignKey("dbo.Offre", "DomaineID", "dbo.Domaine");
            DropIndex("dbo.OffreMotcle", new[] { "MotCleID" });
            DropIndex("dbo.OffreMotcle", new[] { "OffreID" });
            DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" });
            DropIndex("dbo.AspNetUserRoles", new[] { "UserId" });
            DropIndex("dbo.AspNetUserLogins", new[] { "UserId" });
            DropIndex("dbo.AspNetUserClaims", new[] { "User_Id" });
            DropIndex("dbo.Users", new[] { "Utilisateur_ID" });
            DropIndex("dbo.Ville", new[] { "ProvineID" });
            DropIndex("dbo.Sauvegarde", new[] { "OffreID" });
            DropIndex("dbo.Sauvegarde", new[] { "UtilisateurID" });
            DropIndex("dbo.Utilisateur", new[] { "GroupUtilisateurID" });
            DropIndex("dbo.Postule", new[] { "OffreID" });
            DropIndex("dbo.Postule", new[] { "UtilisateurID" });
            DropIndex("dbo.Offre", new[] { "UtilisateurID" });
            DropIndex("dbo.Offre", new[] { "VilleID" });
            DropIndex("dbo.Offre", new[] { "DomaineID" });
            DropTable("dbo.OffreMotcle");
            DropTable("dbo.AspNetUserRoles");
            DropTable("dbo.AspNetUserLogins");
            DropTable("dbo.AspNetUserClaims");
            DropTable("dbo.Users");
            DropTable("dbo.AspNetRoles");
            DropTable("dbo.Provine");
            DropTable("dbo.Ville");
            DropTable("dbo.Sauvegarde");
            DropTable("dbo.GroupUtilisateur");
            DropTable("dbo.Utilisateur");
            DropTable("dbo.Postule");
            DropTable("dbo.MotCle");
            DropTable("dbo.Offre");
            DropTable("dbo.Domaine");
        }
    }
}
